<?php

require('./../../wp-blog-header.php');
//            error_log("User data update into GT".$current_user->user_email."\n", 3, "/my-errors.log");

if (is_user_logged_in()) {
    /*$ogameLogin = xprofile_get_field_data(2, $current_user->id);
    $ogameAlliance = xprofile_get_field_data(3, $current_user->id);
    $ogameUniverse = xprofile_get_field_data(4, $current_user->id);

    if($ogameLogin==''||$ogameUniverse==''){
        header('Location: http://ogame.padre386.myjino.ru/?page_id=29');
        exit();
    }*/

    /*
        $gtData = $wpdb->get_results("SELECT username FROM gt_usertable WHERE username = '" . $current_user->user_login . "'");
        if ($gtData) {
            foreach ($gtData as $gtRow) {
                $wpdb->update('gt_usertable',
                    array('email' => $current_user->user_email),
                    array( 'username' => $current_user->user_login ),
                    array('%s'),
                    array('%s'));
            }
        } else {
            $wpdb->insert('gt_usertable',
                    array('username' => $current_user->user_login,
                    'userpass' => 'wordpress_auth', 'password_salt' => 'wordpress_auth',
                    'email' => $current_user->user_email),
                    array('%s', '%s', '%s', '%s')
                    );

            header('Location: http://ogame.padre386.myjino.ru/?page_id=19');
            //todo send email
            exit();
        }*/
} else {
    header('Location: http://ogame.padre386.myjino.ru/?page_id=14');
    exit();
}











/*// check if user is logged in
if (!isset($_SESSION['s_serverurl']) || (isset($_SESSION['s_serverurl']) && (strpos($_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'],$_SESSION['s_serverurl']) === false))) {
	$path = $_SERVER['PHP_SELF'];
	$pos = strrpos($path,"/");
	$path = substr($path,0,$pos+1);

	// try to restore other session
	require_once GALAXYTOOL_ROOT."/secret/includes/session_handler.inc.php";
	$result = swap_session($_SERVER['HTTP_HOST'].$path);
	if ($result === false) {
		$error_page_code = "timeout";
		if (!isset($NO_PAGE_FORWARD)) {
			include GALAXYTOOL_ROOT."/secret/errorpage.php";
			exit();
		}
	}
	unset($result);
	unset($pos);
	unset($path);
}
if (!isset($_SESSION['s_loggedin']) || ($_SESSION['s_loggedin'] == false)) {
	$error_page_code = "timeout";
	if (!isset($NO_PAGE_FORWARD)) {
		include GALAXYTOOL_ROOT."/secret/errorpage.php";
		exit();
	}
}

// check if session belongs to an outdated Galaxytool version (before upgrade)
if (isset($_SESSION['s_auth']) && $_SESSION['s_auth']->get_logon_version() != VERSION) {
	$error_page_code = "timeout";
	if (!isset($NO_PAGE_FORWARD)) {
		include GALAXYTOOL_ROOT."/secret/errorpage.php";
		exit();
	}
}

// Update last action time at DB if config file was loaded before; Config file is not loaded if no DB connection is required
// do not update last_action in ajax requests
if (strpos($_SERVER['PHP_SELF'], "/ajax_") === false) {
	if (isset($_SESSION['s_auth']) && isset($utablename) && is_numeric($_SESSION['s_auth']->get_setting(iAuthorization::setting_userid))) {
		$query = "UPDATE $utablename SET last_action=now() WHERE id='".$_SESSION['s_auth']->get_setting(iAuthorization::setting_userid)."'";
		mysql_query($query,$global_mysql_con);
	}
}*/

?>